Skip to content

Conversation

@Byron
Copy link
Member

@Byron Byron commented Jan 2, 2026

This PR adds set_dictionary and set_level to the zlib-rs backend, which is now used directly from Rust, without a detour through C-bindings.

Followed up by #525 .

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes zlib-rs support by adding set_dictionary and set_level methods that call zlib-rs directly without requiring C-bindings. The implementation maintains separate counters to track total input/output bytes excluding dictionary data, consistent with the existing C backend approach.

Key Changes:

  • Added native set_dictionary and set_level support for zlib-rs backend
  • Implemented separate total_in/total_out tracking to exclude dictionary bytes from counts
  • Updated zlib-rs dependency from version 0.5.3 to 0.5.4

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Cargo.toml Updated zlib-rs dependency from 0.5.3 to 0.5.4 to support new API features
src/mem.rs Added set_dictionary methods for zlib-rs backend and refactored set_level to support both any_zlib and zlib-rs; updated test configuration for error message test
src/ffi/zlib_rs.rs Added total_in/total_out tracking fields, implemented set_dictionary and set_level methods, and updated error handling to use error_message() from inner state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@joshtriplett joshtriplett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for refactoring and cleaning up.

@Byron Byron merged commit 71eb5c5 into rust-lang:main Jan 8, 2026
15 checks passed
@Byron
Copy link
Member Author

Byron commented Jan 8, 2026

Thanks a lot!

I rebased #525 on top of main, acting as regression protection. During our previous attempt to release zlib-rs without C-bindings, we accidentally broke a bunch of functionality which now wasn't accessible anymore, and the test-suite couldn't catch it. With #525 that changes.

When that is available, I think a new release should be attempted.

EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 12, 2026
Because we no longer depend on it since bc2f339 (GitoxideLabs#2370).

For context on the associated TODO this completes and removes, see:

- rust-lang/flate2-rs#520 (superseded)
- rust-lang/flate2-rs#524
- rust-lang/flate2-rs#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants